#ifndef DEF_MAP_H
#define DEF_MAP_H

#include "common.h"

class Map
{
   public: 
      
      Map();
      Map(const char *map_name);
      ~Map();
      
      bool load(const char *map_name);
      void save(const char *map_name);
      void save();
      
      bool isLoaded();
      
      inline void setSpace(int h, int w) { space_h = h; space_w = w; mapPixDim = pix_dim(mapPixDim.width+space_w*mapDim.width,
                                                                                         mapPixDim.height+space_h*mapDim.height); }
      
      void calc_coord_on_screen(pix_coord p_start = pix_coord());
      
      int tile_on_case[N_LAYER][MAP_DIM_MAX][MAP_DIM_MAX];
      
      inline int& setValue(int L, map_coord c) { return tile_on_case[L][c.iLig][c.iCol]; }
      inline int getValue(int L, map_coord c) { return tile_on_case[L][c.iLig][c.iCol]; }
      
      pix_coord coord_on_screen[N_LAYER][MAP_DIM_MAX][MAP_DIM_MAX];
      string tileset_for_layer[N_LAYER];
            
      pix_coord start;
      int space_h, space_w;
      map_dim mapDim;
      pix_dim mapPixDim;
      
      string map_path_final;
      
   private:

      FILE *map_file;
};

#endif
